﻿using UnityEngine;
using UnityEditor;

[CustomEditor (typeof(Tunnel)), CanEditMultipleObjects]
public class TunnelEditor : Editor {
	public SerializedProperty tunnelDirectionProp, exit1Prop, exit2Prop;
	private Tunnel tunnelScript;

	void OnEnable(){
		tunnelDirectionProp = serializedObject.FindProperty("Direction");
		exit1Prop = serializedObject.FindProperty("exit1");
		exit2Prop = serializedObject.FindProperty("exit2");
		tunnelScript = (Tunnel)target;
	}

	public override void OnInspectorGUI(){
		serializedObject.Update();

		EditorGUILayout.PropertyField(tunnelDirectionProp, new GUIContent("Tunnel Direction"));
		EditorGUI.indentLevel ++;
		switch((TunnelDirection)tunnelDirectionProp.enumValueIndex){
		case TunnelDirection.Horizontal:
			EditorGUILayout.PropertyField(exit1Prop, new GUIContent("Left Exit"));
			EditorGUILayout.PropertyField(exit2Prop, new GUIContent("Right Exit"));
			break;
		case TunnelDirection.Vertical:
			EditorGUILayout.PropertyField(exit1Prop, new GUIContent("Top Exit"));
			EditorGUILayout.PropertyField(exit2Prop, new GUIContent("Bottom Exit"));
			break;
		}
		EditorGUI.indentLevel --;
		serializedObject.ApplyModifiedProperties();
	}

}
